package com.xiaoshuidi.cloud.module.member.service.programarticle;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xiaoshuidi.cloud.framework.common.pojo.PageResult;
import com.xiaoshuidi.cloud.framework.security.core.util.SecurityFrameworkUtils;
import com.xiaoshuidi.cloud.module.member.controller.admin.programarticle.vo.MemberArticleCreateVO;
import com.xiaoshuidi.cloud.module.member.controller.admin.programarticle.vo.MemberArticleRespVO;
import com.xiaoshuidi.cloud.module.member.controller.admin.programarticle.vo.MemberArticlePageVO;
import com.xiaoshuidi.cloud.module.member.mapper.programarticle.MemberArticleMapper;
import com.xiaoshuidi.cloud.module.member.pojo.programarticle.MemberArticle;
import com.xiaoshuidi.cloud.module.member.repository.MemberArticleRepository;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;


@Slf4j
@Service
@RequiredArgsConstructor
public class MemberArticleServiceImpl  extends ServiceImpl<MemberArticleMapper, MemberArticle> implements MemberArticleService{
   private final MemberArticleRepository memberArticleRepository;

    @Override
    public Boolean create(MemberArticleCreateVO vo) {
        memberArticleRepository.create(vo);
        return true;
    }

    @Override
    public PageResult<MemberArticleRespVO> getPage(MemberArticlePageVO pageVo) {
        IPage<MemberArticleRespVO> page= memberArticleRepository.getPage(pageVo);
        PageResult<MemberArticleRespVO> result= PageResult.empty();
        result.setTotal(page.getTotal());
        result.setList(page.getRecords());
        return result;
    }

    @Override
    public Boolean edit(MemberArticleCreateVO vo) {
        memberArticleRepository.edit(vo);
        return true;
    }
}
